const { select, insert,update } = require("../db/db")
const add = async (sql, fields) => {
    // let { lbm } = req.body
    // let fields = { category: lbm }
    // let sql = `commoditycategory`;
    // console.log((await insert(sql, fields))[0])
    return  (await insert(sql, fields))[0]
    // console.log(routs.insertId);
    // res.send({code:0,msg:'success',data:routs.insertId});
}
const select1 = async (sql) => {
    // let sql = `commoditycategory`;
    return await select(sql);
    // console.log(routs);
    // res.send(routs);
}

const upda = async (tablename, data) => {
    // let sql = `commoditycategory`;
    
    return await update(tablename,{
        updateFields:{
            category: `"${data.category}"`,
        },
        where_and: [`id=${data.id}`]
    });
}
module.exports = {
    add,
    select1,
    upda
}